<template>
  <view class="page">
    <u-navbar @leftClick="navLeftClick" :fixed="false" title="销售雷达" placeholder bgColor="#fff"></u-navbar>
    <view class="list" v-if="list.length">
      <view class="item" v-for="item in list" :key="item.logId" @click="jumpTo('/pages/my/mySalesDetail?customerId='+item.customerId)">
        <view class="u-flex u-m-b-20">
          <image style="width: 100rpx;height: 100rpx;margin-right: 26rpx;" :src="item.customerAvatar" mode="aspectFill" />
          <view>
            <view class="u-font-28 u-m-b-18">{{ item.customerName }}</view>
            <view class="u-font-24" style="color: #818181;">推广人员：{{ item.promoterName }}</view>
          </view>
        </view>
        <view class="u-font-28 u-m-b-8">浏览内容：{{ item.contentTitle }}</view>
        <view class="u-font-24" style="color: #333333;">{{ item.createTime }}</view>
      </view>
    </view>
    <a-empty v-else></a-empty>
  </view>
</template>

<script>
import { getLogList } from '@/api/index'

export default {
  data() {
    return {
      pageNum: 1,
      list: [],
      pages: 0,
    };
  },
  onLoad() {
    this.getPage()
  },
  methods: {
    getPage() {
      uni.showLoading({ mask: true })
      getLogList({pageNum: this.pageNum, pageSize: 20, promoterId: uni.getStorageSync('userInfo').userId}).then(res => {
        uni.hideLoading()
        this.list = [...this.list, ...res.rows]
        this.pages = Math.ceil(res.total / 20)
      })
    }
  },
  onReachBottom() {
    if(this.pageNum < this.pages) {
      this.pageNum++
      this.getPage()
    }
  },
};
</script>

<style lang="scss" scoped>
.page {
  width: 750rpx;
  min-height: 100vh;
  background-color: #F5F5F5;
  padding-bottom: 80rpx;
  position: relative;
  .list {
    width: 702rpx;
    margin: 12rpx auto 0;
    display: flex;
    flex-direction: column;
    gap: 12rpx;
    .item {
      width: 100%;
      background-color: #fff;
      border-radius: 12rpx;
      padding: 16rpx 18rpx 22rpx;
    }
  }
}
</style>
